package android.Dominion.Graph;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;

public class GraphNode
{
	private int id;
	private GraphNodeType nodeType;
	private GraphNode parent;
	private List<GraphNode> children;
	private boolean waitForInput;
	private HashMap<String, Object> input;
	private boolean beenProcessed;
	private String descr;
	
	
	public GraphNode()
	{
		children = new ArrayList<GraphNode>();
		beenProcessed = false;
	}

	public void setId(int id)
	{
		this.id = id;
	}

	public int getId()
	{
		return id;
	}

	public void setNodeType(GraphNodeType nodeType)
	{
		this.nodeType = nodeType;
	}

	public GraphNodeType getNodeType()
	{
		return nodeType;
	}

	public void setParent(GraphNode parent)
	{
		this.parent = parent;
	}

	public GraphNode getParent()
	{
		return parent;
	}

	public void setChildren(List<GraphNode> children)
	{
		this.children = children;
	}

	public List<GraphNode> getChildren()
	{
		return children;
	}

	public GraphNode getNextUnprocessedChild()
	{
		GraphNode child = null;
		for (int i = 0; i < children.size(); i++)
		{
			GraphNode tempChild = children.get(i);
			if (!tempChild.hasBeenProcessed())
			{
				child = tempChild;
				break;
			}
		}

		return child;
	}

	public void setWaitForInput(boolean waitForInput)
	{
		this.waitForInput = waitForInput;
	}

	public boolean isWaitForInput()
	{
		return waitForInput;
	}

	public void setInput(HashMap<String, Object> input)
	{
		this.input = input;
	}

	public HashMap<String, Object> getInput()
	{
		return input;
	}

	public void SetInputValue(String key, Object value)
	{
		input.put(key, value);
	}

	public void setBeenProcessed(boolean beenProcessed)
	{
		this.beenProcessed = beenProcessed;
	}

	public boolean hasBeenProcessed()
	{
		return beenProcessed;
	}

	public void AddChild(GraphNode node)
	{
		node.setParent(this);
		children.add(node);
	}

	public void setDescr(String descr)
	{
		this.descr = descr;
	}

	public String getDescr()
	{
		return descr;
	}

}
